package com.rem.hutool.my5Utils;

import cn.hutool.core.util.ArrayUtil;

import java.util.Arrays;

/**
 * 数组工具
 *
 * @author Rem
 * @date 2020-08-24
 */

public class ArrayUtilDemo {

    public static void main(String[] args) {
        //判断空
        int[] a = {};
        boolean empty = ArrayUtil.isEmpty(a);
        System.err.println(empty);


        //创建空数组
        String[] strs = ArrayUtil.newArray(String.class, 3);
        System.err.println(Arrays.toString(strs));

        //调整大小
        String[] resize = ArrayUtil.resize(strs, 5);
        System.err.println(Arrays.toString(resize));


        //合并数组
        strs[0] = "jack";
        resize[0] = "tom";
        String[] merges = ArrayUtil.addAll(strs, resize);
        System.err.println(Arrays.toString(merges));//[jack, null, null, tom, null, null, null, null]


        //克隆
        String[] clone = ArrayUtil.clone(strs);
        System.err.println(Arrays.toString(clone));


        //有序列表
        int[] range = ArrayUtil.range(3, 9);
        System.err.println(Arrays.toString(range));


        //原始类型转包装类型
        Integer[] wrap = ArrayUtil.wrap(range);

        //过滤
       /* Integer[] filter = ArrayUtil.filter(wrap, (Editor<Integer>) t -> (t % 2 == 0) ? t : null);
        System.err.println(Arrays.toString(filter));*/

        //是否包含
        boolean contains = ArrayUtil.contains(range, 7);
        System.err.println(contains);

        //转字符串
        String s = ArrayUtil.toString(range);
        System.err.println(s);
        //带分隔符
        String join = ArrayUtil.join(range, ",");
        System.err.println(join);
    }
}
